import os
import subprocess
import pytest

time_out = 40
opencann_success = 0
opencann_failed = -1
work_path = os.path.join(os.environ.get('OPENCANN_TPATH'), 'bin/')

class TestAicl:
    @pytest.mark.timeout(time_out)
    def test_aicl_init_001(self):
        print('aicl_init_001')
        ret = subprocess.getstatusoutput(work_path + "aicl_init_001")
        assert ret[0] == opencann_success, ret[1]

    @pytest.mark.timeout(time_out)
    def test_aicl_dev_001(self):
        print('aicl_dev_001')
        ret = subprocess.getstatusoutput(work_path + "aicl_dev_001")
        assert ret[0] == opencann_success, ret[1]

    @pytest.mark.timeout(time_out)
    def test_aicl_mem_001(self):
        print('aicl_mem_001')
        ret = subprocess.getstatusoutput(work_path + "aicl_mem_001")
        assert ret[0] == opencann_success, ret[1]

    @pytest.mark.timeout(time_out)
    def test_aicl_mem_002(self):
        print('aicl_mem_002')
        ret = subprocess.getstatusoutput(work_path + "aicl_mem_002")
        assert ret[0] == opencann_success, ret[1]

    @pytest.mark.timeout(time_out)
    def test_aicl_mem_003(self):
        print('aicl_mem_003')
        ret = subprocess.getstatusoutput(work_path + "aicl_mem_003")
        assert ret[0] == opencann_success, ret[1]


    @pytest.mark.timeout(time_out)
    def test_aicl_op_001(self):
        print('aicl_op_001')
        ret = subprocess.getstatusoutput(work_path + "aicl_op_001")
        assert ret[0] == opencann_success, ret[1]

    @pytest.mark.timeout(time_out)
    def test_aicl_op_002(self):
        print('aicl_op_002')
        ret = subprocess.getstatusoutput(work_path + "aicl_op_002")
        assert ret[0] == opencann_success, ret[1]

    @pytest.mark.timeout(time_out)
    def test_aicl_mdl_001(self):
        print('aicl_mdl_001')
        ret = subprocess.getstatusoutput(work_path + "aicl_mdl_001")
        assert ret[0] == opencann_success, ret[1]


class TestGraph:
    @pytest.mark.timeout(time_out)
    def test_graph_edit_001(self):
        print('graph_edit_001')
        ret = subprocess.getstatusoutput(work_path + "graph_edit_001")
        assert ret[0] == opencann_success, ret[1]

    @pytest.mark.timeout(time_out)
    def test_graph_edit_002(self):
        print('graph_edit_002')
        ret = subprocess.getstatusoutput(work_path + "graph_edit_002")
        assert ret[0] == opencann_success, ret[1]

    @pytest.mark.timeout(time_out)
    def test_graph_edit_003(self):
        print('graph_edit_003')
        ret = subprocess.getstatusoutput(work_path + "graph_edit_003")
        assert ret[0] == opencann_success, ret[1]

    @pytest.mark.timeout(time_out)
    def test_graph_edit_004(self):
        print('graph_edit_004')
        ret = subprocess.getstatusoutput(work_path + "graph_edit_004")
        assert ret[0] == opencann_success, ret[1]

    @pytest.mark.timeout(time_out)
    def test_graph_run_001(self):
        print('graph_run_001')
        ret = subprocess.getstatusoutput(work_path + "graph_run_001")
        assert ret[0] == opencann_success, ret[1]

    @pytest.mark.timeout(time_out)
    def test_graph_run_002(self):
        print('graph_run_002')
        ret = subprocess.getstatusoutput(work_path + "graph_run_002")
        assert ret[0] == opencann_success, ret[1]


